package com.hy.demo.learn.thread;

/**
 * <p>
 *  线程的强制执行
 * </p>
 *
 * @author cjl
 * @version 1.0
 * @since 2020-08-21 10:47
 */
public class Join {

    public static void main(String[] args) {

        // 获取霸道线程
        Thread main=Thread.currentThread();

        Thread thread=new Thread(()->{

            for (int i = 0; i < 100; i++) {

                if(i==3){
                    try {
                        main.join();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

                System.out.println("**** 执行数量。i="+i);
            }

        });
        thread.start();

        for (int i = 0; i < 100; i++) {
            System.out.println(" **** 霸道线程数量 i="+i);
        }
    }
}
